fix: anchor Klaviyo proxy endpoint allowlist to the full path shape [] - #11294
Merged
Michael Pineiro (michaelpineirocontentful) merged 6 commits intoSep 14, 2026
Conversation
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio. |
Michael Pineiro (michaelpineirocontentful)
added this pull request to stack #11296
September 9, 2026 20:53
The OAuth callback popup broadcast its completion message with a wildcard target origin, so any window that ended up as window.opener could receive the authorization code and state. Scope the postMessage call to the app's own origin instead of '*'.
…w messages The window message listener that completes the OAuth flow accepted any message posted to the window, regardless of where it came from or which window sent it. Reject messages that don't come from the app's own origin, or that don't come from the popup window this instance actually opened.
The proxy's endpoint allowlist only checked the segment before the first slash, so a value like "template-universal-content/../lists" passed the check while the traversal segment let the request reach a Klaviyo endpoint that was never allowlisted. Replace the prefix check with a pattern anchored to the exact shape the app actually sends (an allowed endpoint, optionally followed by a single id segment), rejecting anything else outright.
Covers exact allowlist matches, an allowlisted endpoint plus a single id segment, and traversal attempts that previously bypassed the prefix-only check (verified these fail against the pre-fix code and pass against the anchored-pattern fix). Widen the vitest include glob to pick up functions/ tests — the functions/ directory previously had no test coverage at all. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Michael Pineiro (michaelpineirocontentful)
force-pushed
the
fix/klaviyo-oauth-message-handler-origin-check
branch
from
September 11, 2026 15:08
bcd963b to
1000f1b
Compare
Michael Pineiro (michaelpineirocontentful)
force-pushed
the
fix/klaviyo-proxy-endpoint-allowlist
branch
from
September 11, 2026 15:08
b97b7cb to
f4aefbc
Compare
Michael Pineiro (michaelpineirocontentful)
marked this pull request as ready for review
September 11, 2026 15:09
Michael Pineiro (michaelpineirocontentful)
requested review from
a team
as code owners
September 11, 2026 15:09
| @@ -8,6 +8,7 @@ import type { | |||
| const KLAVIYO_API_URL = 'https://a.klaviyo.com/api'; | |||
| const KLAVIYO_API_REVISION = '2025-04-15'; | |||
| const ALLOWED_ENDPOINTS = ['template-universal-content', 'images']; | |||
Contributor
There was a problem hiding this comment.
Looks like this is no longer used, we can get rid of it
Contributor
Author
There was a problem hiding this comment.
Good catch — inlined it into the pattern literal directly, no separate binding needed. Fixed in fa7f850.
david-shibley-contentful
approved these changes
Sep 11, 2026
david-shibley-contentful
left a comment
Contributor
There was a problem hiding this comment.
one comment, none blocking
ryunsong-contentful
approved these changes
Sep 11, 2026
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The allowlist check moved to ALLOWED_ENDPOINT_PATTERN; ALLOWED_ENDPOINTS only survived as an internal building block for that regex. Inline it directly into the pattern literal instead of keeping a separate binding nothing else reads. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ryunsong-contentful
approved these changes
Sep 11, 2026
Michael Pineiro (michaelpineirocontentful)
removed this pull request from stack #11296
September 14, 2026 14:09
Michael Pineiro (michaelpineirocontentful)
force-pushed
the
fix/klaviyo-oauth-message-handler-origin-check
branch
from
September 14, 2026 14:09
1000f1b to
813a28c
Compare
Michael Pineiro (michaelpineirocontentful)
merged commit Sep 14, 2026
fa01cfc
into
fix/klaviyo-oauth-message-handler-origin-check
15 checks passed
Michael Pineiro (michaelpineirocontentful)
deleted the
fix/klaviyo-proxy-endpoint-allowlist
branch
September 14, 2026 14:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Klaviyo proxy function's endpoint allowlist only checked the path segment before the first slash. A value like
template-universal-content/../listspassed that check, and the traversal segment let the request reach a Klaviyo API endpoint that was never allowlisted.Solution
Context
Third in a small stack of hardening fixes to the Klaviyo app found during a routine security review. Verified the new pattern still matches every endpoint value the frontend currently sends (bare endpoint names and
endpoint/{id}), while rejecting traversal and encoded-traversal variants.Test plan
tsc --noEmitpassesbuild-functions) succeeds